-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology #71625
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
24cfd0c
to
904a77c
Compare
72bdab5
to
34c5e0c
Compare
34c5e0c
to
241ab21
Compare
src/libcore/ptr/mod.rs
Outdated
@@ -112,11 +112,17 @@ mod mut_ptr; | |||
/// as the compiler doesn't need to prove that it's sound to elide the | |||
/// copy. | |||
/// | |||
/// * It can be used to drop [pinned] data (pinned data must not be moved | |||
/// before it is dropped). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// before it is dropped). | |
/// before it is dropped), except if `T` is `repr(packed). |
I feel currently this reads a bit like a contradiction, where it says "can be used to drop pinned data (because in-place)" but later says "but fields of packed structs are not dropped in-place".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AIUI, packed structs with destructors cannot be pinned to begin with, and packed structs without destructors are presumably safe to drop using this function anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They cannot be pinned precisely because of what this comment says. If someone tries anyway, this is the place where they are violating the rules. So this is the place where that should be mentioned.
The compiler won't stop you when you try to pin something packed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. I put the caveat before the part in brackets because I felt it was awkward to read otherwise.
r? @RalfJung |
241ab21
to
d8a3e59
Compare
…ge of terminology.
d8a3e59
to
7433c4d
Compare
This looks great, thanks a lot. :) |
📌 Commit 7433c4d has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#71625 (Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology) - rust-lang#71919 (Update transitive dependency to work towards removing syn <1.0 dep) - rust-lang#72166 (Simpler slice `Iterator` methods) - rust-lang#72216 (Remove `lang_items\(\).*\.unwrap\(\)`) - rust-lang#72230 (Updated documentation of Prefix::VerbatimDisk) - rust-lang#72234 (Implement Default for proc_macro::TokenStream) - rust-lang#72258 (Fix typo Arbintrary to Arbitrary) Failed merges: r? @ghost
cc @RalfJung
Follow-up from rust-lang/unsafe-code-guidelines#233